public class Login {
    String userName = "huangtao";
    String password = "123456789";

    public void loginFunc(String name, String password) {
        try {
            if (!this.userName.equals(name)) {
                throw new UserNameException("用户名错误！");
            }
            if (!this.password.equals(password)) {
                throw new PasswordException("密码错误！");
            }
            System.out.println("登陆成功！");
        }catch(UserNameException e){
            e.printStackTrace();
        }catch(PasswordException e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Login login = new Login();
        login.loginFunc("tao","123");
    }
}





